/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.muni.fi.pv168.reminder.swing.workers;

import cz.muni.fi.pv168.reminder.entities.Task;
import cz.muni.fi.pv168.reminder.managers.TaskManager;
import cz.muni.fi.pv168.reminder.managers.implementation.TaskManagerImpl;
import cz.muni.fi.pv168.reminder.swing.FrameMainWindow;
import javax.swing.SwingWorker;

/**
 *
 * @author Adic
 */
public class GetTaskSwingWorker extends SwingWorker<Task, Void> {
        Long ID;
        
        public GetTaskSwingWorker(Long taskID) {
            ID = taskID;
        }

        @Override
        protected Task doInBackground() throws Exception {
            Task task = null;            
            TaskManager taskManager = new TaskManagerImpl();            

            taskManager.setDataSource(FrameMainWindow.getDataSource());

            task = taskManager.findTaskById(ID);
            
            return task;
        }
    }
